<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include  page="../common/file.jsp"/>
<head>
</head>
<body>
<script type="text/javascript">
	//初始化滚动条
	$("html").niceScroll({cursorcolor:"#000000",zindex:999999,bouncescroll:true,cursoropacitymax:0.4,cursorborder:"",cursorborderradius:7,cursorwidth:"7px",background:"rgba(0,0,0,.1)",autohidemode:true,railpadding:{top:0,right:2,left:2,bottom:0}});
	//页面信息提示
	var returnMsg = "${_error}";
	var authoriMsg = "${_authoriError}";
</script>
<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
    <ol class="breadcrumb page-breadcrumb pull-left">
        <li><i class="fa fa-home"></i>&nbsp;<a href="${pageContext.request.contextPath}/role/list">系统管理</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;</li>
        <li class="active">角色管理</li>
    </ol>
</div>
<div style="clear:both"></div>
<div class="main-right-content">
	<div class="main-right-div">
		<div class="main-right-query-div">
			<form id="query-form-1" action="${pageContext.request.contextPath}/role/list" method="post">
			<div class="main-right-search row">
				<div class="col-lg-2">
                	<button type="button" class="btn btn-red btn-add">新 增</button>
                </div>
			</div>
			</form>
		</div>
		<div style="clear: both;"></div>
		<div class="main-right-table-div">
			<table class="main-right-table">
				<colgroup>
					<col style="width:5%;">
					<col style="width:10%;">
					<col style="width:15%;">
					<col style="width:6%;">
					<col style="width:8%;">
				</colgroup>
				<thead>
					<tr>
						<td>序列</td>
						<td>角色名称</td>
						<td>描述</td>
						<td>状态</td>
						<td>操作</td>
					</tr>
				</thead>
				<tbody>
					<c:if test="${list != null && list.size() > 0}">
					<c:forEach items="${list}" var="d" varStatus="st">
						<tr>
							<td style="text-align: center;"><span>${d.orderNo}</span></td>
							<%-- <td style="text-align: center;"><span>${d.roleId}</span></td> --%>
							<td style="text-align: center;"><span>${d.roleName}</span></td>
							<td style="text-align: center;"><span>${d.remark}</span></td>
							<td style="text-align: center;">
								<c:if test="${d.status == '1'}">
									<span>有效</span>
								</c:if>
								<c:if test="${d.status == '0'}">
									<span>无效</span>
								</c:if>
							</td>
							<td style="text-align: center;">
								<c:if test="${d.roleId != '1'}">
									<a data-id="<c:out value='${d.roleId}'/>" class="stylebuttonwee stylemedium stylesquare styleblue2 row-grant-btn" href="javascript:void(0);">授权</a>
									&nbsp;
									<a data-id="<c:out value='${d.roleId}'/>" class="stylebuttonwee stylemedium stylesquare stylegreen row-update-btn" href="javascript:void(0);">修改</a>
									&nbsp;
									<a data-id="<c:out value='${d.roleId}'/>" class="stylebuttonwee stylemedium stylesquare stylegrey row-delete-btn" href="javascript:void(0);">删除</a>
								</c:if>
							</td>
						</tr>
					</c:forEach>
					</c:if>
					<c:if test="${list == null || list.size() <= 0}">
						<tr>
							<td colspan="6" style="padding: 5px;text-align: center;">查询无记录！</td>
						</tr>
					</c:if>
				</tbody>
			</table>
		</div>
	</div>
</div>
	<script type="text/javascript">

		var ctxt = "${pageContext.request.contextPath}";
		// 新增角色
		$('.btn-add').click(function() {
			art.dialog.open(ctxt + '/role/create', {
				title: '新增角色',width: 380,height: 260,lock: true,opacity: 0.3
			});
		});
		
		// 授权角色
		$('.row-grant-btn').click(function() {
			var roleId = $(this).data('id');
			art.dialog.open(ctxt + '/role/grantView?roleId='+roleId, {
				title: '角色授权',width: 400,height: 460,lock: true,opacity: 0.3
			});
		});
		
		// 修改角色
		$('.row-update-btn').click(function() {
			var roleId = $(this).data('id');
			art.dialog.open(ctxt + '/role/edit?roleId='+roleId, {
				title: '修改角色',width: 380,height: 260,lock: true,opacity: 0.3
			});
		});
		
		// 删除角色
		$('.row-delete-btn').click(function() {
			var roleId = $(this).data('id');
			art.dialog.confirm('你确定要删除该角色吗？', function () {
				art.dialog.tips('正在提交...', 0.5);
				$.post(ctxt + "/role/delete", {"roleId": roleId}, function(msg) {
					if (msg != undefined && msg.status == 0) {
						art.dialog.alert(msg.message, function() {
							$('#query-form-1').submit();
						}); 
					} else {
						art.dialog.tips(msg.message, 2);
					}
				},'json');
			}, function () {
			    art.dialog.tips('执行已取消', 0.3);
			});
		});
		
	</script>
</body>